Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
how to mock [].filter.call(document.getElementbyTag('link'), (e1: any) => e1.rel ==='stylesheet') in jasmine unit case?

I'm removing the css file dynamically to change the theme in angular application.

Theme change will happen based on the routing, I am listen/subscribe the router events in a service. Inside constructor I am calling below function

 public clearHeader() { 
    const headers =  [].filter.call(document.getElementbyTagName('link'), (e1: any) => e1.rel ==='stylesheet');  
    headers.forEach((ele)=> { document.head.removechild(ele)
  });

When I am spyOn clearHeader() method in jasmine unit testing, it is removing css files from the dom, so in the another test case when try to call the clearHeader() method I'm getting below error Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. which means the css files are removed, there are no css files so I want to know how to mock [].filter.call method in angular service spec file. so that test cases won't remove the css files from the DOM

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!